.. _Evaluate NeurEco Compression model with the Python API:

Evaluate NeurEco Compression model with the Python API
===========================================================

To evaluate a NeurEco Compression model in Python API, import **NeurEcoTabular** library:

.. code-block:: python

  from NeurEco import NeurEcoTabular as Tabular
	
Initialize a NeurEco object to handle the **Compressor** problem:

.. code-block:: python

  model = Tabular.Compressor()
	
:std:ref:`Build NeurEco Compression model with the Python API` or load previously build and saved to *"the/path/to/the/saved/compression/model.ernn"* model:

.. code-block:: python

  model.load("the/path/to/the/saved/compression/model.ernn")

Once **model** contains a compression decompression model, call method **evaluate** with the parameters set accordingly:

.. code-block:: python

  model.evaluate(inputs, vec=None)

Evaluates a Tabular model on a set of input data.

:inputs: required, NumPy array: input data array: shape (n, m) where n is the number of samples and m is the number of input features.
:vec: optional, NumPy array: perform evaluation with the model's weights set to values in vec.

:return: NumPy array:  output data array: shape (n, p) where n is the number of samples and p is the number of output features.

		
Evaluate the compression coefficients and decompress them
---------------------------------------------------------
		
Any Compression **model** can be divided in its **model_Compressor** and **model_Decompressor** parts via the call to **separate_models** method, both of them are Regression models:

.. code-block:: python

  neurEco_Compressor = Tabular.Regressor()
  neurEco_Decompressor = Tabular.Regressor()
  separate_status = model.separate_models(neurEco_Compressor, neurEco_Decompressor)
	
To evaluate the compression coefficients (the evaluation for a Regression model is the same as for a Compression model, see :std:ref:`Evaluate NeurEco Regression model with the Python API`):

.. code-block::python

  compression_coefficients = neurEco_Compressor.evaluate(inputs)
	
To decompress the obtained array **compression_coefficients**:

.. code-block::python

  decompressed_output = neurEco_Decompressor.evaluate(compression_coefficients)
	
The obtained **decompressed_output** is equal to the **output** obtained with original Compression **model**.
